package com.dingwei.superiordiary.adapter.easyViewHolder;

import android.support.v4.content.ContextCompat;
import android.text.style.ClickableSpan;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.app.MyApplication;
import com.dingwei.superiordiary.bean.CommentBean;
import com.dingwei.superiordiary.utils.SpannableStringUtils;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.lihao.baselibrary.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by lihao on 2017/9/12.
 */

public class FindDetailsEvaluationItemHolder extends BaseViewHolder<CommentBean.DataBean.ListBean.SubBean> {


    @Bind(R.id.tv_content)
    TextView tvContent;
    @Bind(R.id.img_like)
    ImageView imgLike;
    @Bind(R.id.tv_like_num)
    TextView tvLikeNum;
    @Bind(R.id.like_layout)
    LinearLayout likeLayout;
    @Bind(R.id.tv_add_time)
    TextView tvAddTime;

    public FindDetailsEvaluationItemHolder(ViewGroup parent) {
        super(parent, R.layout.item_details_evaluation_item);
        ButterKnife.bind(this, itemView);

    }

    @Override
    public void setData(CommentBean.DataBean.ListBean.SubBean data) {
        super.setData(data);

        tvContent.setText(SpannableStringUtils.getBuilder(data.nickname)
                .setClickSpan(new ClickableSpan() {
            @Override
            public void onClick(View view) {

            }
        }).setForegroundColor(ContextCompat.getColor(BaseActivity.context,R.color.selected_bg_color)).append(data.content).create() );


        tvContent.setText(data.content);
        tvAddTime.setText(data.addtime);
        if (data.is_liked==2){
            imgLike.setImageResource(R.mipmap.ic_comment_liked);
        }else {
            imgLike.setImageResource(R.mipmap.ic_comment_not_like);
        }
        tvLikeNum.setText(data.likes);
    }
}
